package com.yayo.mangement.security.entity;

import com.yayo.mangement.info.UserInfo;
import com.yayo.mangement.model.SysUser;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;

/**
 * @UserInfo:
 * @author: Yayo
 * @date: 2022/8/30 21:08
 */
@Data
@ToString
@EqualsAndHashCode
@AllArgsConstructor
public class User implements UserDetails {

    private UserInfo sysUser;

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    @Override
    public String getPassword() {
        System.out.println(sysUser.getUserPassword() + "=================");
        return sysUser.getUserPassword();
    }

    @Override
    public String getUsername() {
        return sysUser.getUserLoginName();
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
